package com.gitee.sdlszjb.exception;


/**
 * 文件描述
 *
 * @author 庄壮壮
 * @since 2021-01-09 14:02
 */
public class AniviaException extends RuntimeException {
    private int code;
    private String message;

    public static AniviaException create(int code, String message) {
        AniviaException antdException = new AniviaException();
        antdException.code = code;
        antdException.message = message;
        return antdException;
    }
    public static AniviaException create(String message) {
        AniviaException antdException = new AniviaException();
        antdException.code = 400;
        antdException.message = message;
        return antdException;
    }

    public AniviaException() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static AniviaException idNotExists(Long id) {
        return create(400, "ID不存在: " + id);
    }

    public static AniviaException idNotExists(String id) {
        return create(400, " ID不存在: " + id);
    }

    public static AniviaException paramsError() {
        return create(400, "请求参数错误");
    }
}
